package com.example.kai.uno.Ranking;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.ListView;

import com.example.kai.uno.MyDBHelper;
import com.example.kai.uno.R;


public class MyFragment3 extends Fragment {
    private static final String TAG = "MyFragment3";
    String b[];
    String []c={"暂时没有新数据"};
    private MyDBHelper dbHelper;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.listview_content, container, false);
        ListView list_content = (ListView) view.findViewById(R.id.list_content);


        dbHelper = new MyDBHelper(getActivity(),"UserStore.db",null,1);
        SQLiteDatabase db = dbHelper.getWritableDatabase();
        Cursor cr = db.query("scoreData2", null, null, null, null, null, "score desc");
        String[] ColumnNames = {"_id","score","time"};

        ListAdapter adapter = new MySimpleCursorAdapter(getActivity(), R.layout.listviewlayout, cr, ColumnNames, new int[] { R.id.name, R.id.score, R.id.time });

        list_content.setAdapter(adapter);

        Log.i(TAG, "onCreateView: 0000--------MyFragment1");
        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        Log.i(TAG, "onDestroyView: 0000-------MyFragment3");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i(TAG, "onDestroy: 0000--------MyFragment3");
    }

    public MyFragment3() {
    }

}
